
const jwt = require('jsonwebtoken')
const secret = "asxxbbn-back"//解密密钥

const JWT = {
  createToken: (data, time = 5184000) => {
    // time 5184000 60天
    return jwt.sign(data, secret, { expiresIn: time })
  },
  verifyToken: (token) => {
    // 如果token过期或验证失败，将返回false
    try {
      return jwt.verify(token, secret)
    } catch (error) {
      return false
    }
  }
}

module.exports = JWT